﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using SPPD.model;
using SPPD.controller;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;
using NHibernate.Linq;

namespace SPPD
{
    /// <summary>
    /// Interaction logic for Window4.xaml
    /// </summary>
    public partial class Window4 : Window
    {
        public int no;
        public sppd sppdTolak = new sppd();
        public pegawai pegawaiLogin = new pegawai();
        public Window4(int idx, sppd sTolak, pegawai pgawai)
        {
            InitializeComponent();
            no = idx;
            sppdTolak = sTolak;
            pegawaiLogin = pgawai;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (no == 1)
            {
                bendahara_sppd sppd = new bendahara_sppd(pegawaiLogin);
                this.Hide(); sppd.Show();
            }
            else
            {
                bendahara_spj spj = new bendahara_spj(pegawaiLogin);
                this.Hide(); spj.Show();
            }
            /*pegawai dummy_pegawai= new pegawai();
            nhibernate nhi = new nhibernate();
            /*var factory = nhi.CreateSessionFactory();
            using (var session = factory.OpenSession())
            {
                var categories = session.Query<pegawai>()
                       .OrderBy(c => c.nama)
                       .ToList();

                for (int i = 0; i < categories.Count; i++)
                {
                    if (categories[i].nama == textBox1.Text)
                    {
                        dummy_pegawai = categories[i];
                        break;
                    }
                }
            }*/
            var dummy = new transaksi
            {
                pengoreksi = pegawaiLogin,
                alasan = textBox1.Text,
                koreksi = textBox2.Text,
                saran = textBox3.Text,
                id = 5,
                status_transaksi = 1,
                sppd = sppdTolak
                
            };*/
            con.insert(dummy);
        }
    }
}
